/**
 * @FileName: PositionRequest.java
 * @Package:com.bdtop.dbl.server.apis
 * @Description: TODO
 * @author: wangpeng
 * @date:2014-10-10
 * @version V1.0
 */

package com.bdtop.dbl.server.request;

import com.bdtop.dbl.server.response.FenceAddResponse;
import com.bdtop.dbl.thirdparty.asynchttp.HttpPostRequest;
import com.bdtop.dbl.thirdparty.asynchttp.RequestCallback;
import com.bdtop.dbl.utils.Constants;
import com.bdtop.dbl.utils.DBLDebug;
import com.google.gson.Gson;

/**
 * @ClassName: FenceRequest
 * @Description: TODO
 * @author: wangpeng
 * @date:2014-10-13
 */
public class FenceAddRequest extends HttpPostRequest {

    /**
     * @param callback
     */
    public FenceAddRequest(RequestCallback callback) {
        super(callback);
        getRequestParams().add(Constants.COMMAND, Constants.CMD_ADD_FENCE);
    }

    public void setParams(String sign, String mdn, String fencename, String lon
            , String lat, String radius) {
        getRequestParams().add(Constants.PARAM_LOGIN_SIGN, sign);
        getRequestParams().add(Constants.PARAM_MDN, mdn);
        getRequestParams().add(Constants.PARAM_FENCENAME, fencename);
        getRequestParams().add(Constants.PARAM_LON, lon);
        getRequestParams().add(Constants.PARAM_LAT, lat);
        getRequestParams().add(Constants.PARAM_RADIUS, radius);
        
    }

    @Override
    protected String getUrl() {
        return Constants.SERVER_ADDRESS;
    }

    @Override
    protected Object parse(String responseString) {
        DBLDebug.logd("FenceAddRequest, response = " + responseString);

        Gson gson = new Gson();
        FenceAddResponse response = gson.fromJson(responseString, FenceAddResponse.class);
        return response;
    }

}
